#![allow(dead_code)]

struct EnvLrn {}

impl EnvLrn {
    pub fn hello() {
        println!("Env learning!");
    }
}

#[cfg(test)]
mod tests {
    #[test]
    fn test_current_dir() -> std::io::Result<()> {
        let path = std::env::current_dir()?;
        println!("The current directory is {}", path.display());
        Ok(())
    }

    #[test]
    fn test_join_path() -> std::io::Result<()> {
        let path = std::env::current_dir()?;
        let new_path = path.join("a").join("b");
        println!("The new path is {}", new_path.display());
        Ok(())
    }

    #[test]
    fn test_var() {
        let key = "HOME";
        match std::env::var(key) {
            Ok(val) => println!("{}: {:?}", key, val),
            Err(e) => println!("couldn't interpret {}: {}", key, e),
        }

        std::env::set_var("KEY", "VALUE");
        assert_eq!(std::env::var("KEY"), Ok("VALUE".to_string()));
    }
}
